using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;

public class AutoRotate : TriggerItem
{
    // Start is called before the first frame update
    void Start()
    {
        if (!StartOnAwake)
            return;

        Play();
    }
    
    public override void Play()
    {
        var angle = transform.localEulerAngles;
        angle += new Vector3(0, 0, 360f);
        var tween = transform.DOLocalRotate(angle, Duration, RotateMode.FastBeyond360)
            .SetEase(Ease.Linear);
        if (isLoop)
            tween.SetLoops(-1, LoopType.Incremental);
    }

    void OnDestroy()
    {
        transform.DOKill();
    }
}
